package com.orange.lswidget.widgets.musicplayer;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

import com.orange.lswidget.LSWidgetManager;
import com.orange.lswidget.LSWidgetProvider;
import com.orange.lswidget.R;
import com.orange.lswidget.widgets.musicplayer.service.MusicLSWidgetService;
import com.orange.util.LogHelper;

public class MusicLSWidgetProvider extends LSWidgetProvider {
	static final String					TAG					= "MusicLSWidgetProvider";

	private static final String			MY_PACKAGE_NAME		= "com.orange.lswidget";
	public static final ComponentName	MY_COMPONENT_NAME	= new ComponentName(
																	MY_PACKAGE_NAME,
																	MusicLSWidgetProvider.class
																			.getName());

	@Override
	public void onReceive(Context context, Intent intent) {
		super.onReceive(context, intent);
	}

	@Override
	public void onEnabled(Context context) {
		super.onEnabled(context);
		LogHelper.e(TAG, "onEnabled. ");
		MusicLSWidgetService.startService(context);
	}

	@Override
	public void onUpdate(Context context, int viewType) {
		super.onUpdate(context, viewType);
		LogHelper.e(TAG, "onUpdate. ");
		MusicLSWidgetService.startService(context);
		RemoteViews remoteViews = new RemoteViews(
				MusicLSWidgetProvider.MY_PACKAGE_NAME, R.layout.music);
		LSWidgetManager.updateLSWidgetType(viewType, remoteViews, false);
	}

	@Override
	public void onDeleted(Context context) {
		LogHelper.e(TAG, "onDeleted. ");
		MusicLSWidgetService.stopService(context);
		super.onDeleted(context);
	}

	@Override
	public void onDisabled(Context context) {
		LogHelper.e(TAG, "onDisabled. ");
		MusicLSWidgetService.stopService(context);
		super.onDisabled(context);
	}

}
